import sys
import os

"""
自己插入cv2，为了保存图片或者视频
"""
import cv2
# import argparse
from yolo import YOLO, detect_video  # detect_video
from PIL import Image


def detect_img(yolo):
    print('hahahha')
    with open("./temp_imagepath.txt", 'r') as file:
        contents = file.readlines()
        print("content:{}".format(contents))
        # print(content)
    path = os.path.basename(contents)
    print(path)
    img = './Raw_image/' + (path)
    print("img:{}".format(img))
    image = Image.open(img)
    count_box, r_image = yolo.detect_image(image)
    print('***********figure_save*******************')
    r_image.show()
    r_image.save('./Detect_image/download.jpg')
    yolo.close_session()
    print("yolo结束了")


if __name__ == "__main__":
    detect_img(YOLO())
